import Router from 'koa-router'
import User from '../controls/users.js'
import { Auth } from '../middleware/Auth.js'
import { getTokenUser } from '../middleware/getTokenUser.js'

const router = new Router({ prefix: '/api/user' })
router.get('/', User.find)
router.get('/checkUser', User.checkUser)
router.post('/login', User.login)
router.post('/register', User.create)
router.post('/update', Auth, User.checkOwner, User.update)
router.get('/my', Auth, User.getMyInfo)
router.get('/getUserInfo', getTokenUser, User.getUserInfo)
router.post('/infoUpdate', Auth, User.checkOwner, User.updateInfo)
router.post('/upload_avatar', Auth, User.uploadAvatar)
router.post('/following', Auth, User.following)
router.post('/unfollowing', Auth, User.unFollowing)
router.get('/getFollowers', getTokenUser, User.getFollowers) // 获取粉丝列表
router.get('/getFollowings', getTokenUser, User.getFollowings) // 获取关注列表

export default router